<?php
    include_once 'config.php';

    $query = "SELECT * FROM societe";
    $employees = pg_query($pgdb, $query);

    if (!$employees) {
        echo 'An error occurred.';
        exit();
    }
    //$query = "INSERT INTO societe(nom, siret, adress) VALUES('Sophea', '455DW', 'Str 23, Phnome Cambodia')";
?>
<h1>List Societe</h1>
<a href="add-societe.php">New Societe</a>
<table>
    <thead>
        <tr>
            <th>ID</th>
            <th>Nom</th>
            <th>Adress</th>
            <th>&nbsp;</th>
        </tr>
    </thead>
    <tbody>
<?php while ($emp = pg_fetch_object($employees)) : ?>
    <tr>
        <td><?php echo $emp->id_societe ?></td>
        <td><?php echo $emp->nom ?></td>
        <td><?php echo $emp->adress ?></td>
        <td>
            <a href="edit.php?id=<?php echo $emp->id_societe ?>">Edit</a>
            <a href="delete.php?id=<?php echo $emp->id_societe ?>">Delete</a>
        </th>
    </tr>
<?php endwhile; ?>
    </tbody>
</table>
